package com.bw.zg3park2212.adpter

import android.graphics.Color
import android.widget.TextView
import com.bw.base.entity.FangEntityItem

import com.bw.zg3park2212.R
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class FangAdpter:BaseQuickAdapter<FangEntityItem,BaseViewHolder>(R.layout.item_fang) {
    override fun convert(helper: BaseViewHolder, item: FangEntityItem) {

        helper.setText(R.id.fang_time,item.appointmentTime)
        helper.setText(R.id.fang_name,item.visitorName)
        helper.setText(R.id.fang_phone,item.phoneNumber)
        helper.setText(R.id.fang_becose,item.purpose)
        val fangState = helper.getView<TextView>(R.id.fang_state)
        if (item.visitStatus=="已通过"){
            helper.setText(R.id.fang_state,"已通过")
            fangState.setTextColor( Color.parseColor("#5EA18A"))
            fangState.setBackgroundResource(R.drawable.bg_tongguo)
        }else if (item.visitStatus=="待审核"){
            fangState.setTextColor( Color.parseColor("#C49466"))
            fangState.setBackgroundResource(R.drawable.bg_daishenhe)
            fangState.setText("待审核")
        }else if (item.visitStatus=="驳回"){
            fangState.setTextColor( Color.parseColor("#4169E0"))
            fangState.setBackgroundResource(R.drawable.bg_zganyong)
            fangState.setText("驳回")
        } else{
            fangState.setTextColor( Color.parseColor("#616976"))
            fangState.setBackgroundResource(R.drawable.bg_wancheng)
            fangState.setText("已完成")
        }
        val fangBloon = helper.getView<TextView>(R.id.fang_bloon)
        if (item!!.approved){
            fangBloon.text="已申请访客车位"
            fangBloon.setTextColor( Color.parseColor("#1E87E4"))
        }else{
            fangBloon.text="未申请访客车位"
        }
    }
}